/*
 * @Descripttion:
 * @version:
 * @Author: ChenXiang
 * @Date: 2021-05-25 14:04:25
 * @LastEditors: ChenXiang
 * @LastEditTime: 2021-05-25 14:50:04
 */
import React from "react";
import ReactDOM from "react-dom";
const modalRoot = document.getElementById("modal-root");

export default class Modal extends React.Component {
  constructor(props) {
    super(props);
    this.el = document.createElement("div");
  }

  componentDidMount() {
    modalRoot.appendChild(this.el);
  }

  componentWillUnmount() {
    modalRoot.removeChild(this.el);
  }

  render() {
    return ReactDOM.createPortal(this.props.children, this.el);
  }
}
